// promise 手写  
// 不要正面硬刚，解题，了解promise细节 
// class promise
// constructor cb() 
// this.state 状态 三种 pending fullfiled rejected
// 由pending开始 resolve -> fullfiled reject rejected
// 一旦状态改变，就不可再变
const promise = new Promise((resolve,reject) => {
    resolve('success1'); // promise pending -> fullfiled
    reject('error');
    resolve('success2');
})

promise
    .then(res => {
        console.log("then",res);
    })
    .catch(err => {

    })